/*
ID: guoxu1
PROG: milk2
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

#define cin fin
#define cout fout
struct N
{
	int begin;
	int end;
	bool ignore;

	N()
	{
		ignore = false;
	}

	int width() { return end - begin; }
	bool operator < ( const N& n ) const
	{
		return begin < n.begin;
	}
};

int main()
{
	ifstream fin( "milk2.in" );
	ofstream fout( "milk2.out" );
	vector<N> F;

	int count = 0;
	cin >> count;
	if( count == 0 ) return 0;

	for( int i = 0; i < count; i++ )
	{
		N n;
		cin >> n.begin >> n.end;

		vector<N>::iterator it;
		for( it = F.begin(); it != F.end(); it++ )
		{
			if( it->ignore ) continue;

			N m;
			m.begin = std::min( it->begin, n.begin );
			m.end = std::max( it->end, n.end );

			if( m.end - m.begin <= it->width() + n.width() )
			{
				it->ignore = true;
				it = F.begin();
				n = m;
			}
		}
		F.push_back( n );
	}

	for( vector<N>::iterator it = F.begin(); it != F.end(); )
	{
		if( it->ignore )
		{
			it = F.erase( it );
		}
		else
		{
			it++;
		}
	}
	std::sort( F.begin(), F.end() );

	int m1 = 0;
	int m2 = 0;
	int last_end = -1;
	for( vector<N>::const_iterator it = F.begin(); it != F.end(); it++ )
	{
		if( m1 < it->end - it->begin )
		{
			m1 = it->end - it->begin;
		}
		if( last_end != -1 && m2 < it->begin - last_end )
		{
			m2 = it->begin - last_end;
		}
		last_end = it->end;
	}
	cout << m1 << " " << m2 << endl;

	return 0;
}
